# 定义class的getter/setter方法

# class MVVM(object):
#     def __init__(self, attr):
#         self.__attr = attr
#     @property
#     def attr(self):
#         return '''
#         the attr is %s
#         ''' % self.__attr
#     @property
#     def nm(self):
#         return self.__nm
#     @nm.setter
#     def nm(self, value):
#         self.__nm = value
#         self.__attr = value + self.__attr

# page = MVVM('page')

# # 重写对象属性的getter/setter
# print(page.attr)
# page.nm = 'hello'
# print(page.attr)

class Screen(object):
    @property
    def width(self):
        return self.__width
    @width.setter
    def width(self, value):
        self.__width = value
    @property
    def height(self):
        return self.__height
    @height.setter
    def height(self, value):
        self.__height = value
    @property
    def resolution(self):
        return 786432

s = Screen()
s.width = 1024
s.height = 768
print('resolution =', s.resolution)
if s.resolution == 786432:
    print('测试通过!')
else:
    print('测试失败!')

print(s.width)